package com.mk.admin.service.impl;

import com.mk.admin.mapper.DoctorConsultationMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.DoctorConsultationEntity;
import com.mk.admin.model.query.DoctorConsultationQuery;
import com.mk.admin.model.vo.DoctorConsultationVo;
import com.mk.admin.service.DoctorConsultationService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorConsultationServiceImpl implements DoctorConsultationService {
    @Autowired
    private DoctorConsultationMapper doctorConsultationMapper;

    @Override
    public ResultDto select(DoctorConsultationQuery query) {
        DoctorConsultationEntity entity = JSONCopy.copy(query, DoctorConsultationEntity.class);
        return ResultDto.data(doctorConsultationMapper.count(entity), doctorConsultationMapper.select(entity));
    }

    @Override
    public ResultDto last(DoctorConsultationQuery query) {
        DoctorConsultationEntity entity = JSONCopy.copy(query, DoctorConsultationEntity.class);
        return ResultDto.data(doctorConsultationMapper.last(entity));
    }

    @Override
    public ResultDto add(DoctorConsultationVo doctorConsultationVo) {
        return ResultDto.data(doctorConsultationMapper.insert(JSONCopy.copy(doctorConsultationVo, DoctorConsultationEntity.class)));
    }

    @Override
    public ResultDto update(DoctorConsultationVo doctorConsultationVo) {
        return ResultDto.data(doctorConsultationMapper.updateById(JSONCopy.copy(doctorConsultationVo, DoctorConsultationEntity.class)));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(doctorConsultationMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(doctorConsultationMapper.status(id));
    }
}
